﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:Controls="clr-namespace:MahApps.Metro.Controls"
                    xmlns:Converters="clr-namespace:MahApps.Metro.Converters">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.CheckBox.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <Converters:ToUpperConverter x:Key="ToUpperConverter" />
    <BooleanToVisibilityConverter x:Key="bool2VisibilityConverter" />

    <Style x:Key="MetroDataGridCheckBox"
           TargetType="CheckBox"
           BasedOn="{StaticResource MetroCheckBox}">
        <Setter Property="Margin"
                Value="0" />
        <Setter Property="HorizontalAlignment"
                Value="Center" />
        <Setter Property="VerticalAlignment"
                Value="Center" />
        <Style.Triggers>
            <DataTrigger Binding="{Binding Path=IsReadOnly, RelativeSource={RelativeSource AncestorType=DataGridCell}}"
                         Value="True">
                <Setter Property="IsHitTestVisible"
                        Value="False" />
            </DataTrigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="{ComponentResourceKey ResourceId=MetroDataGridSelectAllButtonStyle, TypeInTargetAssembly={x:Type DataGrid}}"
           TargetType="{x:Type Button}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Grid>
                        <Rectangle x:Name="Border"
                                   SnapsToDevicePixels="True">
                            <Rectangle.Resources>
                                <Style TargetType="{x:Type Rectangle}">
                                    <Setter Property="Fill"
                                            Value="{DynamicResource GrayBrush7}" />
                                </Style>
                            </Rectangle.Resources>
                        </Rectangle>
                        <Polygon x:Name="Arrow"
                                 Fill="{DynamicResource GrayBrush1}"
                                 HorizontalAlignment="Right"
                                 Margin="8,8,3,3"
                                 Opacity="0.15"
                                 Points="0,10 10,10 10,0"
                                 Stretch="Uniform"
                                 VerticalAlignment="Bottom" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsPressed"
                                 Value="True">
                            <Setter Property="Fill"
                                    TargetName="Border"
                                    Value="{DynamicResource AccentColorBrush2}" />
                        </Trigger>
                        <Trigger Property="IsEnabled"
                                 Value="False">
                            <Setter Property="Visibility"
                                    TargetName="Arrow"
                                    Value="Collapsed" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="MetroColumnHeaderGripperStyle"
           TargetType="{x:Type Thumb}">
        <Setter Property="Width"
                Value="8" />
        <Setter Property="Background"
                Value="{DynamicResource GrayBrush5}" />
        <Setter Property="Cursor"
                Value="SizeWE" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Border Padding="{TemplateBinding Padding}"
                            Background="Transparent">
                        <Rectangle HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                   Width="1"
                                   Fill="{TemplateBinding Background}" />
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="MetroRowHeaderGripperStyle"
           TargetType="{x:Type Thumb}">
        <Setter Property="Height"
                Value="6" />
        <Setter Property="Background"
                Value="{DynamicResource GrayBrush5}" />
        <Setter Property="Cursor"
                Value="SizeNS" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Border Padding="{TemplateBinding Padding}"
                            Background="Transparent">
                        <Rectangle VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                   Height="1"
                                   Fill="{TemplateBinding Background}" />
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="MetroDataGridColumnHeader"
           TargetType="{x:Type DataGridColumnHeader}">
        <Setter Property="SnapsToDevicePixels"
                Value="True" />
        <Setter Property="MinWidth"
                Value="0" />
        <Setter Property="MinHeight"
                Value="25" />
        <Setter Property="Foreground"
                Value="{DynamicResource BlackBrush}" />
        <Setter Property="Cursor"
                Value="Hand" />
        <Setter Property="HorizontalContentAlignment"
                Value="Left" />
        <Setter Property="VerticalContentAlignment"
                Value="Center" />
        <Setter Property="Padding"
                Value="10,4,4,7" />
        <Setter Property="Margin"
                Value="0,0,0,0" />
        <Setter Property="BorderThickness"
                Value="0,0,0,3" />
        <Setter Property="BorderBrush"
                Value="{DynamicResource GrayBrush5}" />
        <Setter Property="Background"
                Value="{DynamicResource GrayBrush8}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type DataGridColumnHeader}">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <Border x:Name="BackgroundBorder"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                Grid.ColumnSpan="2"
                                Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}" />

                        <ContentPresenter x:Name="HeaderContent"
                                          Content="{TemplateBinding Content}"
                                          ContentTemplate="{TemplateBinding ContentTemplate}"
                                          Margin="{TemplateBinding Padding}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          RecognizesAccessKey="True"
                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />

                        <Path x:Name="SortArrow"
                              Visibility="Collapsed"
                              Stretch="Fill"
                              Grid.Column="1"
                              Width="8"
                              Height="10"
                              Margin="0,0,8,2"
                              VerticalAlignment="Center"
                              RenderTransformOrigin="0.5,0.5"
                              Fill="{DynamicResource GrayBrush2}" />

                        <Thumb x:Name="PART_LeftHeaderGripper"
                               HorizontalAlignment="Left"
                               HorizontalContentAlignment="Left"
                               Background="Transparent"
                               Style="{StaticResource MetroColumnHeaderGripperStyle}" />

                        <Thumb x:Name="PART_RightHeaderGripper"
                               HorizontalAlignment="Right"
                               HorizontalContentAlignment="Right"
                               Style="{StaticResource MetroColumnHeaderGripperStyle}"
                               Grid.Column="1" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="SortDirection"
                                 Value="{x:Null}">
                            <Setter TargetName="BackgroundBorder"
                                    Property="Background"
                                    Value="{DynamicResource WhiteBrush}" />
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver"
                                           Value="True" />
                                <Condition Property="SortDirection"
                                           Value="{x:Null}" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="BackgroundBorder"
                                    Property="Background"
                                    Value="{DynamicResource GrayBrush8}" />
                        </MultiTrigger>

                        <Trigger Property="SortDirection"
                                 Value="Ascending">
                            <Setter TargetName="SortArrow"
                                    Property="Visibility"
                                    Value="Visible" />
                            <Setter TargetName="SortArrow"
                                    Property="Data"
                                    Value="F1 M 34,57L 42,57L 42,32.25L 52,42.25L 52,31.75L 38,17.75L 24,31.75L 24,42.25L 34,32.25L 34,57 Z " />
                        </Trigger>
                        <Trigger Property="SortDirection"
                                 Value="Descending">
                            <Setter TargetName="SortArrow"
                                    Property="Visibility"
                                    Value="Visible" />
                            <Setter TargetName="SortArrow"
                                    Property="Data"
                                    Value="F1 M 42,19.0002L 34,19.0002L 34,43.7502L 24,33.7502L 24,44.2502L 38,58.2502L 52,44.2502L 52,33.7502L 42,43.7502L 42,19.0002 Z " />
                            <Setter TargetName="SortArrow"
                                    Property="Margin"
                                    Value="0,0,8,0" />
                        </Trigger>
                        <Trigger Property="DisplayIndex"
                                 Value="0">
                            <Setter Property="Visibility"
                                    Value="Collapsed"
                                    TargetName="PART_LeftHeaderGripper" />
                        </Trigger>
                        <Trigger Property="IsEnabled"
                                 Value="False">
                            <Setter Property="Foreground"
                                    Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="ContentTemplate">
            <Setter.Value>
                <DataTemplate>
                    <TextBlock FontWeight="SemiBold"
                               Text="{Binding Converter={StaticResource ToUpperConverter}}" />
                </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="MetroDataGridRowHeader"
           TargetType="{x:Type DataGridRowHeader}">
        <Setter Property="HorizontalContentAlignment"
                Value="Stretch" />
        <Setter Property="VerticalContentAlignment"
                Value="Center" />
        <Setter Property="Background"
                Value="Transparent" />
        <Setter Property="BorderBrush"
                Value="{DynamicResource GrayBrush5}" />
        <Setter Property="BorderThickness"
                Value="0,0,1,0" />
        <Setter Property="Margin"
                Value="0,0,0,0" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type DataGridRowHeader}">
                    <Grid>
                        <Border BorderBrush="{TemplateBinding BorderBrush}"
                                Background="{TemplateBinding Background}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                Padding="{TemplateBinding Padding}"
                                Margin="{TemplateBinding Margin}"
                                SnapsToDevicePixels="True">
                            <StackPanel Orientation="Horizontal">
                                <ContentPresenter RecognizesAccessKey="True"
                                                  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" />
                                <Control SnapsToDevicePixels="false"
                                         Template="{Binding ValidationErrorTemplate, RelativeSource={RelativeSource AncestorType={x:Type DataGridRow}}}"
                                         Visibility="{Binding (Validation.HasError), Converter={StaticResource bool2VisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGridRow}}}" />
                            </StackPanel>
                        </Border>
                        <Thumb x:Name="PART_TopHeaderGripper"
                               VerticalContentAlignment="Top"
                               VerticalAlignment="Top"
                               Background="Transparent"
                               Style="{StaticResource MetroRowHeaderGripperStyle}" />
                        <Thumb x:Name="PART_BottomHeaderGripper"
                               VerticalContentAlignment="Bottom"
                               VerticalAlignment="Bottom"
                               Style="{StaticResource MetroRowHeaderGripperStyle}" />
                    </Grid>

                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver"
                                 Value="True">
                            <Setter Property="Background"
                                    Value="{DynamicResource AccentColorBrush3}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--____________________ Metro CellStyle ____________________-->
    <Style x:Key="MetroDataGridCell"
           TargetType="{x:Type DataGridCell}">
        <Setter Property="Controls:DataGridCellHelper.SaveDataGrid"
                Value="True" />
        <Setter Property="Background"
                Value="Transparent" />
        <Setter Property="BorderBrush"
                Value="Transparent" />
        <Setter Property="HorizontalContentAlignment"
                Value="Stretch" />
        <Setter Property="VerticalContentAlignment"
                Value="Center" />
        <Setter Property="SnapsToDevicePixels"
                Value="True" />
        <Setter Property="Padding"
                Value="0" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type DataGridCell}">
                    <Border BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Background="{TemplateBinding Background}"
                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                        <ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}"
                                          Content="{TemplateBinding Content}"
                                          ContentStringFormat="{TemplateBinding ContentStringFormat}"
                                          Margin="{TemplateBinding Padding}"
                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" />
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>

            <!-- IsSelected -->
            <Trigger Property="IsSelected"
                     Value="True">
                <Setter Property="Foreground"
                        Value="{DynamicResource MetroDataGrid.HighlightTextBrush}" />
            </Trigger>
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding Path=(Controls:DataGridCellHelper.DataGrid).SelectionUnit, RelativeSource={RelativeSource Self}}"
                               Value="Cell" />
                    <Condition Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource Self}}"
                               Value="true" />
                </MultiDataTrigger.Conditions>
                <Setter Property="Background"
                        Value="{DynamicResource MetroDataGrid.HighlightBrush}" />
                <Setter Property="BorderBrush"
                        Value="{DynamicResource MetroDataGrid.HighlightBrush}" />
            </MultiDataTrigger>
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding Path=(Controls:DataGridCellHelper.DataGrid).SelectionUnit, RelativeSource={RelativeSource Self}}"
                               Value="CellOrRowHeader" />
                    <Condition Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource Self}}"
                               Value="true" />
                </MultiDataTrigger.Conditions>
                <Setter Property="Background"
                        Value="{DynamicResource MetroDataGrid.HighlightBrush}" />
                <Setter Property="BorderBrush"
                        Value="{DynamicResource MetroDataGrid.HighlightBrush}" />
            </MultiDataTrigger>

            <!-- IsKeyboardFocusWithin -->
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding Path=(Controls:DataGridCellHelper.DataGrid).SelectionUnit, RelativeSource={RelativeSource Self}}"
                               Value="Cell" />
                    <Condition Binding="{Binding Path=IsKeyboardFocusWithin, RelativeSource={RelativeSource Self}}"
                               Value="true" />
                </MultiDataTrigger.Conditions>
                <Setter Property="BorderBrush"
                        Value="{DynamicResource MetroDataGrid.FocusBorderBrush}" />
            </MultiDataTrigger>
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding Path=(Controls:DataGridCellHelper.DataGrid).SelectionUnit, RelativeSource={RelativeSource Self}}"
                               Value="CellOrRowHeader" />
                    <Condition Binding="{Binding Path=IsKeyboardFocusWithin, RelativeSource={RelativeSource Self}}"
                               Value="true" />
                </MultiDataTrigger.Conditions>
                <Setter Property="BorderBrush"
                        Value="{DynamicResource MetroDataGrid.FocusBorderBrush}" />
            </MultiDataTrigger>

            <!-- IsSelected and Selector.IsSelectionActive -->
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsSelected"
                               Value="true" />
                    <Condition Property="Selector.IsSelectionActive"
                               Value="false" />
                </MultiTrigger.Conditions>
                <Setter Property="Foreground"
                        Value="{DynamicResource MetroDataGrid.InactiveSelectionHighlightTextBrush}" />
            </MultiTrigger>
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding Path=(Controls:DataGridCellHelper.DataGrid).SelectionUnit, RelativeSource={RelativeSource Self}}"
                               Value="Cell" />
                    <Condition Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource Self}}"
                               Value="true" />
                    <Condition Binding="{Binding Path=(Selector.IsSelectionActive), RelativeSource={RelativeSource Self}}"
                               Value="false" />
                </MultiDataTrigger.Conditions>
                <Setter Property="Background"
                        Value="{DynamicResource MetroDataGrid.InactiveSelectionHighlightBrush}" />
                <Setter Property="BorderBrush"
                        Value="{DynamicResource MetroDataGrid.InactiveSelectionHighlightBrush}" />
            </MultiDataTrigger>
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding Path=(Controls:DataGridCellHelper.DataGrid).SelectionUnit, RelativeSource={RelativeSource Self}}"
                               Value="CellOrRowHeader" />
                    <Condition Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource Self}}"
                               Value="true" />
                    <Condition Binding="{Binding Path=(Selector.IsSelectionActive), RelativeSource={RelativeSource Self}}"
                               Value="false" />
                </MultiDataTrigger.Conditions>
                <Setter Property="Background"
                        Value="{DynamicResource MetroDataGrid.InactiveSelectionHighlightBrush}" />
                <Setter Property="BorderBrush"
                        Value="{DynamicResource MetroDataGrid.InactiveSelectionHighlightBrush}" />
            </MultiDataTrigger>

            <!-- IsMouseOver -->
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding Path=(Controls:DataGridCellHelper.DataGrid).SelectionUnit, RelativeSource={RelativeSource Self}}"
                               Value="Cell" />
                    <Condition Binding="{Binding Path=IsMouseOver, RelativeSource={RelativeSource Self}}"
                               Value="true" />
                </MultiDataTrigger.Conditions>
                <Setter Property="Background"
                        Value="{DynamicResource MetroDataGrid.MouseOverHighlightBrush}" />
                <Setter Property="BorderBrush"
                        Value="{DynamicResource MetroDataGrid.MouseOverHighlightBrush}" />
            </MultiDataTrigger>
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding Path=(Controls:DataGridCellHelper.DataGrid).SelectionUnit, RelativeSource={RelativeSource Self}}"
                               Value="CellOrRowHeader" />
                    <Condition Binding="{Binding Path=IsMouseOver, RelativeSource={RelativeSource Self}}"
                               Value="true" />
                </MultiDataTrigger.Conditions>
                <Setter Property="Background"
                        Value="{DynamicResource MetroDataGrid.MouseOverHighlightBrush}" />
                <Setter Property="BorderBrush"
                        Value="{DynamicResource MetroDataGrid.MouseOverHighlightBrush}" />
            </MultiDataTrigger>

            <!-- IsEnabled -->
            <Trigger Property="IsEnabled"
                     Value="False">
                <Setter Property="Foreground"
                        Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
            </Trigger>

            <!-- IsEnabled and IsSelected -->
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsEnabled"
                               Value="false" />
                    <Condition Property="IsSelected"
                               Value="true" />
                </MultiTrigger.Conditions>
                <Setter Property="Foreground"
                        Value="{DynamicResource MetroDataGrid.HighlightTextBrush}" />
            </MultiTrigger>
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding Path=(Controls:DataGridCellHelper.DataGrid).SelectionUnit, RelativeSource={RelativeSource Self}}"
                               Value="Cell" />
                    <Condition Binding="{Binding Path=IsEnabled, RelativeSource={RelativeSource Self}}"
                               Value="false" />
                    <Condition Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource Self}}"
                               Value="true" />
                </MultiDataTrigger.Conditions>
                <Setter Property="Background"
                        Value="{DynamicResource MetroDataGrid.DisabledHighlightBrush}" />
                <Setter Property="BorderBrush"
                        Value="{DynamicResource MetroDataGrid.DisabledHighlightBrush}" />
            </MultiDataTrigger>
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding Path=(Controls:DataGridCellHelper.DataGrid).SelectionUnit, RelativeSource={RelativeSource Self}}"
                               Value="CellOrRowHeader" />
                    <Condition Binding="{Binding Path=IsEnabled, RelativeSource={RelativeSource Self}}"
                               Value="false" />
                    <Condition Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource Self}}"
                               Value="true" />
                </MultiDataTrigger.Conditions>
                <Setter Property="Background"
                        Value="{DynamicResource MetroDataGrid.DisabledHighlightBrush}" />
                <Setter Property="BorderBrush"
                        Value="{DynamicResource MetroDataGrid.DisabledHighlightBrush}" />
            </MultiDataTrigger>

        </Style.Triggers>
    </Style>

    <ControlTemplate x:Key="DefaultRowValidationErrorTemplate">
        <Grid VerticalAlignment="Center"
              Margin="2 0 2 0"
              DataContext="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGridRow}}, Path=(Validation.Errors).CurrentItem}"
              ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=DataContext.ErrorContent}">
            <Path Height="20"
                  Width="20"
                  Stretch="Uniform"
                  Fill="{DynamicResource ControlsValidationBrush}"
                  Data="m 31.630585,39.233818 24.6309,-24.6308 c 0.6183,-0.6184 1.6208,-0.6184 2.2392,0 l 24.6308,24.6308 c 0.6184,0.6184 0.6184,1.6209 0,2.2392 l -24.6308,24.6309 c -0.6183,0.6183 -1.6209,0.6183 -2.2392,0 l -24.6309,-24.6309 c -0.6183,-0.6183 -0.6183,-1.6208 0,-2.2392 z" />
            <Path Height="10"
                  Width="10"
                  HorizontalAlignment="Center"
                  VerticalAlignment="Center"
                  Stretch="Uniform"
                  Fill="{DynamicResource ValidationTextBrush}"
                  Data="m 53.781741,31.196677 c -2.237724,0 -4.0625,1.824776 -4.0625,4.0625 0,2.237724 1.824776,4.0625 4.0625,4.0625 2.237724,0 4.0625,-1.824776 4.0625,-4.0625 0,-2.237724 -1.824776,-4.0625 -4.0625,-4.0625 z m -4.09375,-21.375 0.03125,0.53125 1.21875,19.46875 5.6875,0 1.25,-20 -8.1875,0 z" />
        </Grid>
    </ControlTemplate>

    <!--____________________ Metro RowStyle ____________________-->
    <!-- Don't set the MinHeight or Height property, use the MinRowHeight or RowHeight property on DataGrid style! -->
    <Style x:Key="MetroDataGridRow"
           TargetType="{x:Type DataGridRow}">
        <Setter Property="Controls:DataGridRowHelper.SelectionUnit"
                Value="{Binding Path=SelectionUnit, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" />
        <Setter Property="Margin"
                Value="0,0,0,0" />
        <Setter Property="Validation.ErrorTemplate"
                Value="{x:Null}" />
        <Setter Property="ValidationErrorTemplate"
                Value="{StaticResource DefaultRowValidationErrorTemplate}" />
        <Style.Triggers>

            <!-- IsSelected -->
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding Path=(Controls:DataGridRowHelper.SelectionUnit), RelativeSource={RelativeSource Self}}"
                               Value="FullRow" />
                    <Condition Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource Self}}"
                               Value="true" />
                </MultiDataTrigger.Conditions>
                <Setter Property="Background"
                        Value="{DynamicResource MetroDataGrid.HighlightBrush}" />
                <Setter Property="Foreground"
                        Value="{DynamicResource MetroDataGrid.HighlightTextBrush}" />
                <Setter Property="BorderBrush"
                        Value="{DynamicResource MetroDataGrid.HighlightBrush}" />
            </MultiDataTrigger>

            <!-- IsSelected and Selector.IsSelectionActive -->
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding Path=(Controls:DataGridRowHelper.SelectionUnit), RelativeSource={RelativeSource Self}}"
                               Value="FullRow" />
                    <Condition Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource Self}}"
                               Value="true" />
                    <Condition Binding="{Binding Path=(Selector.IsSelectionActive), RelativeSource={RelativeSource Self}}"
                               Value="false" />
                </MultiDataTrigger.Conditions>
                <Setter Property="Background"
                        Value="{DynamicResource MetroDataGrid.InactiveSelectionHighlightBrush}" />
                <Setter Property="BorderBrush"
                        Value="{DynamicResource MetroDataGrid.InactiveSelectionHighlightBrush}" />
                <Setter Property="Foreground"
                        Value="{DynamicResource MetroDataGrid.InactiveSelectionHighlightTextBrush}" />
            </MultiDataTrigger>

            <!-- IsMouseOver -->
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding Path=(Controls:DataGridRowHelper.SelectionUnit), RelativeSource={RelativeSource Self}}"
                               Value="FullRow" />
                    <Condition Binding="{Binding Path=IsMouseOver, RelativeSource={RelativeSource Self}}"
                               Value="true" />
                </MultiDataTrigger.Conditions>
                <Setter Property="Background"
                        Value="{DynamicResource MetroDataGrid.MouseOverHighlightBrush}" />
                <Setter Property="BorderBrush"
                        Value="{DynamicResource MetroDataGrid.MouseOverHighlightBrush}" />
            </MultiDataTrigger>

            <!-- IsEnabled -->
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding Path=(Controls:DataGridRowHelper.SelectionUnit), RelativeSource={RelativeSource Self}}"
                               Value="FullRow" />
                    <Condition Binding="{Binding Path=IsEnabled, RelativeSource={RelativeSource Self}}"
                               Value="false" />
                </MultiDataTrigger.Conditions>
                <Setter Property="Foreground"
                        Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
            </MultiDataTrigger>

            <!-- IsEnabled and IsSelected -->
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding Path=(Controls:DataGridRowHelper.SelectionUnit), RelativeSource={RelativeSource Self}}"
                               Value="FullRow" />
                    <Condition Binding="{Binding Path=IsEnabled, RelativeSource={RelativeSource Self}}"
                               Value="false" />
                    <Condition Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource Self}}"
                               Value="true" />
                </MultiDataTrigger.Conditions>
                <Setter Property="Foreground"
                        Value="{DynamicResource MetroDataGrid.HighlightTextBrush}" />
                <Setter Property="Background"
                        Value="{DynamicResource MetroDataGrid.DisabledHighlightBrush}" />
                <Setter Property="BorderBrush"
                        Value="{DynamicResource MetroDataGrid.DisabledHighlightBrush}" />
            </MultiDataTrigger>

        </Style.Triggers>
    </Style>

    <Style x:Key="MetroDataGrid"
           TargetType="{x:Type DataGrid}">
        <Setter Property="MinRowHeight"
                Value="25" />
        <Setter Property="GridLinesVisibility"
                Value="All" />
        <Setter Property="Background"
                Value="{DynamicResource WhiteBrush}" />
        <Setter Property="BorderBrush"
                Value="{DynamicResource AccentColorBrush}" />
        <Setter Property="BorderThickness"
                Value="0,0,0,0" />
        <Setter Property="HorizontalGridLinesBrush"
                Value="{DynamicResource GrayBrush7}" />
        <Setter Property="VerticalGridLinesBrush"
                Value="{DynamicResource GrayBrush7}" />
        <Setter Property="ColumnHeaderStyle"
                Value="{StaticResource MetroDataGridColumnHeader}" />
        <Setter Property="RowHeaderStyle"
                Value="{StaticResource MetroDataGridRowHeader}" />
        <Setter Property="CellStyle"
                Value="{StaticResource MetroDataGridCell}" />
        <Setter Property="RowStyle"
                Value="{StaticResource MetroDataGridRow}" />
        <Setter Property="HeadersVisibility"
                Value="Column" />
        <Setter Property="DropLocationIndicatorStyle">
            <Setter.Value>
                <Style TargetType="Separator">
                    <Setter Property="Background"
                            Value="{DynamicResource GrayBrush7}" />
                    <Setter Property="Width"
                            Value="2" />
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="Separator">
                                <Rectangle Fill="{TemplateBinding Background}"
                                           Height="{TemplateBinding Height}"
                                           Width="{TemplateBinding Width}" />
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type DataGrid}">
                    <Border BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Background="{TemplateBinding Background}"
                            Padding="{TemplateBinding Padding}"
                            SnapsToDevicePixels="True">
                        <ScrollViewer x:Name="DG_ScrollViewer"
                                      Focusable="false">
                            <ScrollViewer.Template>
                                <ControlTemplate TargetType="{x:Type ScrollViewer}">
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto" />
                                            <ColumnDefinition Width="*" />
                                            <ColumnDefinition Width="Auto" />
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="*" />
                                            <RowDefinition Height="Auto" />
                                        </Grid.RowDefinitions>
                                        <Button Command="{x:Static DataGrid.SelectAllCommand}"
                                                Focusable="false"
                                                Style="{DynamicResource {ComponentResourceKey ResourceId=MetroDataGridSelectAllButtonStyle, TypeInTargetAssembly={x:Type DataGrid}}}"
                                                Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.All}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"
                                                Width="{Binding CellsPanelHorizontalOffset, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" />
                                        <DataGridColumnHeadersPresenter x:Name="PART_ColumnHeadersPresenter"
                                                                        Grid.Column="1"
                                                                        Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.Column}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" />
                                        <Grid Grid.Row="1"
                                              Grid.ColumnSpan="2">
                                            <ScrollContentPresenter x:Name="PART_ScrollContentPresenter"
                                                                    CanContentScroll="{TemplateBinding CanContentScroll}"
                                                                    Grid.ColumnSpan="2" />
                                        </Grid>
                                        <ScrollBar x:Name="PART_VerticalScrollBar"
                                                   Grid.Column="2"
                                                   Maximum="{TemplateBinding ScrollableHeight}"
                                                   Orientation="Vertical"
                                                   Grid.Row="1"
                                                   Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
                                                   Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"
                                                   ViewportSize="{TemplateBinding ViewportHeight}" />
                                        <Grid Grid.Column="1"
                                              Grid.Row="2">
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="{Binding NonFrozenColumnsViewportHorizontalOffset, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" />
                                                <ColumnDefinition Width="*" />
                                            </Grid.ColumnDefinitions>
                                            <ScrollBar x:Name="PART_HorizontalScrollBar"
                                                       Grid.Column="1"
                                                       Maximum="{TemplateBinding ScrollableWidth}"
                                                       Orientation="Horizontal"
                                                       Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
                                                       Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"
                                                       ViewportSize="{TemplateBinding ViewportWidth}" />
                                        </Grid>
                                    </Grid>
                                </ControlTemplate>
                            </ScrollViewer.Template>
                            <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        </ScrollViewer>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsGrouping"
                     Value="true">
                <Setter Property="ScrollViewer.CanContentScroll"
                        Value="false" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="AzureDataGridColumnHeader"
           TargetType="{x:Type DataGridColumnHeader}"
           BasedOn="{StaticResource MetroDataGridColumnHeader}">
        <Setter Property="Margin"
                Value="0,0,0,10" />
    </Style>

    <Style x:Key="AzureDataGridRowHeader"
           TargetType="{x:Type DataGridRowHeader}"
           BasedOn="{StaticResource MetroDataGridRowHeader}">
        <Setter Property="BorderThickness"
                Value="0,0,0,0" />
    </Style>

    <!--____________________ Azure CellStyle ____________________-->
    <Style x:Key="AzureDataGridCell"
           TargetType="{x:Type DataGridCell}"
           BasedOn="{StaticResource MetroDataGridCell}">
        <Setter Property="BorderThickness"
                Value="0" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type DataGridCell}">
                    <Border BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Background="{TemplateBinding Background}"
                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                        <ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}"
                                          Content="{TemplateBinding Content}"
                                          ContentStringFormat="{TemplateBinding ContentStringFormat}"
                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          Margin="1" />
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <DataTrigger Binding="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=Column.DisplayIndex}"
                         Value="0">
                <Setter Property="Background"
                        Value="{DynamicResource AccentColorBrush4}" />
            </DataTrigger>
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=Column.DisplayIndex}"
                               Value="0" />
                    <Condition Binding="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=IsSelected}"
                               Value="True" />
                </MultiDataTrigger.Conditions>
                <Setter Property="Background"
                        Value="{DynamicResource AccentColorBrush2}" />
            </MultiDataTrigger>
        </Style.Triggers>
    </Style>

    <!--____________________ Azure RowStyle ____________________-->
    <Style x:Key="AzureDataGridRow"
           TargetType="{x:Type DataGridRow}"
           BasedOn="{StaticResource MetroDataGridRow}">
    </Style>
    <Style x:Key="AzureDataGridRowWithMargin"
           TargetType="{x:Type DataGridRow}"
           BasedOn="{StaticResource AzureDataGridRow}">
        <Setter Property="Margin"
                Value="0,0,0,1" />
    </Style>

    <Style x:Key="AzureDataGrid"
           TargetType="{x:Type DataGrid}"
           BasedOn="{StaticResource MetroDataGrid}">
        <Setter Property="ColumnHeaderStyle"
                Value="{StaticResource AzureDataGridColumnHeader}" />
        <Setter Property="CellStyle"
                Value="{StaticResource AzureDataGridCell}" />
        <Setter Property="RowStyle"
                Value="{StaticResource AzureDataGridRow}" />
        <Setter Property="RowHeaderStyle"
                Value="{StaticResource AzureDataGridRowHeader}" />
        <Style.Triggers>
            <Trigger Property="GridLinesVisibility"
                     Value="None">
                <Setter Property="RowStyle"
                        Value="{StaticResource AzureDataGridRowWithMargin}" />
            </Trigger>
        </Style.Triggers>
    </Style>

</ResourceDictionary>